Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: refactor labels #1145

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

fix: refactor labels #1145

wants to merge 1 commit into from

Conversation

3em
Copy link
Collaborator

@3em 3em commented Feb 21, 2025

Adjusted multiple components to the design
Added missing functionalities:

  • remove label at PR page
  • navigate to edit labels from the label dropdown
    Fixed the Icon component size: in flex containers, it could shrink

Design changes (before/after):

image

image

image

image

image

image

image

@3em 3em requested a review from knagurski as a code owner February 21, 2025 11:42
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link

netlify bot commented Feb 21, 2025

Deploy Preview for harness-design ready!

Name Link
🔨 Latest commit b9f6a26
🔍 Latest deploy log https://app.netlify.com/sites/harness-design/deploys/67c0ad3bfac4f90008b7c8f8
😎 Deploy Preview https://deploy-preview-1145--harness-design.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Feb 21, 2025

Deploy Preview for harness-xd-review ready!

Name Link
🔨 Latest commit b9f6a26
🔍 Latest deploy log https://app.netlify.com/sites/harness-xd-review/deploys/67c0ad3bc681e60008e124d2
😎 Deploy Preview https://deploy-preview-1145--harness-xd-review.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure I follow why this file/hook exists in the first place.
cc @cjlee01 @sans-harness can we discuss once?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hook was created to populate data in the store (useLabelsStore). It's used on the labels list page and on the repository label details page. Essentially, it's just isolated code moved into a hook to fill the store, avoiding repetitive code.

width={width || size}
height={height || size}
className={className}
style={{ minWidth: `${width || size}px`, minHeight: `${height || size}px` }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious why this was needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Icon component is often used in layouts in a way that unintentionally reduces its width (e.g., due to flex), which is incorrect behavior. This code ensures that the icon maintains its width in any layout.

>
{!!value && <span className="max-w-full truncate">{value}</span>}

{!!counter && counter}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this means that counting from 0 is not allowed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes you are right, 0 not allowed

)}
</span>

{isDynamic && <Icon name="circle-plus" size={12} className="min-w-3 text-icons-4" />}
Copy link
Collaborator

@knagurski knagurski Feb 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this have any meaning that as screen reader should be made aware of?

)}

{hasShortcut && !!shortcutLetter && (
<div className="absolute right-1.5 top-1/2 flex h-5 -translate-y-1/2 cursor-pointer items-center gap-0.5 rounded-sm border bg-background-3 px-1 text-foreground-2 duration-100 ease-in-out">
<Icon name="apple-shortcut" size={12} />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to annoy everyone who's not on a Mac.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@knagurski that's a fair point :) But I think it'd be better to move this to a separate task, if you don't mind?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, totally, just an observation when we were in the area

if (!branchError) return

if (pullReqMetadata?.merged || pullReqMetadata?.closed) {
return setShowRestoreBranchButton(true)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best to only return cleanup functions from a useEffect. This will be fine, but it's probably best to separate the call and the return since they aren't really connected.

Suggested change
return setShowRestoreBranchButton(true)
setShowRestoreBranchButton(true)
return

@@ -13,14 +13,16 @@ export interface UseFullFillLabelStoreProps {
export const useFullFillLabelStore = ({ queryPage, query, enabled = true }: UseFullFillLabelStoreProps) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick question about the naming... is it "full fill" as in two words, or "fulfil" as in to complete something? Maybe it would be more obvious what the purpose of the hook was as something like usePopulateLabelsStore or usePrimeLabelsStore?

import { cn } from '@utils/cn'
import { ColorsEnum } from '@views/labels'
import { ColorsEnum, ILabelType, LabelType } from '@views/labels'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we find a way to avoid references to the views from within components? Ideally this should be one-way to make it clear that views bring components together into a cohesive interface, leaving components as independent building blocks. Perhaps should LabelMarker be a subcomponent of the Labels view?

<span
className={`flex h-full items-center overflow-hidden rounded-r bg-label-background-black pl-1.5 pr-[7px] ${inTable && 'max-w-[50%]'}`}
<div className={cn('flex max-w-full items-center gap-2 opa relative', className)}>
<span
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This being a span (an inline element), but being set as display grid (a block level element) doesn't really make much sense to me. Is there a reason we can't use a div? Makes no difference, but I'm curious if there's a reason as I've seen inline elements being changed to block a lot in this codebase 🤔

Comment on lines +58 to +59
const isWithExtraContent = !!value || !!counter
const isWithDeleteButton = !!onDelete
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can totally ignore this since it makes zero difference... instead of isWith, has reads better IMO

Suggested change
const isWithExtraContent = !!value || !!counter
const isWithDeleteButton = !!onDelete
const hasExtraContent = !!value || !!counter
const hasDeleteButton = !!onDelete

@@ -43,7 +43,7 @@ TableHeader.displayName = 'TableHeader'

const TableBody = forwardRef<HTMLTableSectionElement, HTMLAttributes<HTMLTableSectionElement>>(
({ className, ...props }, ref) => (
<tbody ref={ref} className={cn('[&_tr:last-child]:border-0', className)} {...props} />
<tbody ref={ref} className={cn('[&_tr:last-child]:border-0 [&>tr:hover]:bg-background-4', className)} {...props} />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me a change of colour on hover denotes that something is clickable. This might be the ideal for the usage in the labels work, but I don't think we can make that call for all tables. Can we make this opt-in as, perhaps, an extra prop?

return label.assigned_value?.id ?? undefined
}

return undefined
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to manually return undefined; if you don't return anything, you'll get the same

Suggested change
return undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants